/**
 * 
 */
package com.demo2do.edoos.web.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.demo2do.edoos.dao.UserDaoSupport;

/**
 * @author Downpour
 */
@Controller
@RequestMapping("")
public class HomeController {
	
	@Autowired
	private UserDaoSupport userDaoSupport;

	/**
	 * 
	 * @return
	 */
	@RequestMapping("/login")
	public ModelAndView login(@RequestParam("name") String name, @RequestParam("password") String password) {
		
		ModelAndView modelAndView = new ModelAndView("home");
		
		boolean success = userDaoSupport.login(name, password);
		
		modelAndView.addObject("flag", success);
		
		return modelAndView;
		
	}
	
	/**
	 * 
	 * @return
	 */
	@RequestMapping("/json")
	public @ResponseBody String json() {
		
		// return your json string here
		
		return "";
	}
	
}
